/********************************************************************

Write Date: 2015/04/26
Author: Apple
>>>> Create class ResourceLoader

*********************************************************************/
#pragma once
#include "ooputils_global.h"
#include <QDataStream>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include "Object.h"
#include "Ptr.h"



_NS_OOP_BEGIN



/**
 * Class ResourceLoader provides the function to load data from a binary stream.
 * It can recovery the complete structure of data, include Ptr references. for 
 * Objects, polymorphism is supported.
 *
 * Thread-safe: false.
 *
 * @remarks 2015/04/26, Apple
 */
class ResourceLoader
{
public:

	ResourceLoader ();

	P_Object loadObject (const QString& r_name);

	template< class T >
	ResourceLoader& operator>> (T& r_data);

	template< class T >
	ResourceLoader& operator>> (Ptr< T >& rp_data);

	template< class T >
	ResourceLoader& operator>> (std::complex< T >& r_val);
	
	template< class T1, class T2 >
	ResourceLoader& operator>> (std::pair< T1, T2 >& r_val);
	
	template< class T, class _ALLOC >
	ResourceLoader& operator>> (std::vector< T, _ALLOC >& r_val);

	template< class T, class _ALLOC >
	ResourceLoader& operator>> (std::set< T, _ALLOC >& r_val);

	template< class T1, class T2, class _PR, class _ALLOC >
	ResourceLoader& operator>> (std::map< T1, T2, _PR, _ALLOC >& r_val);

	template< class T >
	void readArray (T* data, size_t count);

	template< class T, class _ALLOC >
	void readSimpleVector (std::vector< T, _ALLOC >& r_vector);

private:

	QDataStream _inStream;

};



_NS_OOP_END



#include "ResourceLoader.hpp"